﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Xinkui.WebModel.BasicControl;
using Xinkui.WebModel.Model;

public partial class UserControl_fore_UC_Crumbs : ForeControl {
    protected void Page_Load(object sender, EventArgs e) {
       
    }

    protected override void OnPreRender(EventArgs e) {
        base.OnPreRender(e);

        var navs = BasePage.GetNavs();

        List<string> navHTML = new List<string>(navs.Count);

        while (navs.Count > 0) {
            navHTML.Add(CreateHTML(navs.Dequeue()));
        }
        rptNavs.DataSource = navHTML;
        rptNavs.DataBind();
    }


    public string CreateHTML(NavItem nav) {
        if (!string.IsNullOrEmpty(nav.Link)) {
            return string.Format(@"<a href=""{0}"">{1}</a>", nav.Link, nav.Title);
        }
        else {
            return nav.Title;
        }
    }
}